<?php

class m120917_014339_attach_expense_to_token extends CDbMigration
{
	public function safeUp()
	{
		$this->addColumn('erp_material_expense', 'accountTokenId', 'int');
		$this
			->createIndex("material_expense_account_token_id", 'erp_material_expense', 'accountTokenId');
		$this
			->addForeignKey('fk_material_expense_account_token_id', 'erp_material_expense',
			'accountTokenId', 'erp_account_token', 'id', 'SET NULL', 'CASCADE');

	}

	public function safeDown()
	{
		$this->dropForeignKey('fk_material_expense_account_token_id', 'erp_material_expense');
		$this->dropIndex("material_expense_account_token_id", 'erp_material_expense');
		$this->dropColumn('erp_material_expense', 'accountTokenId');
		
	}
}